package leetcode.code1855;

import leetcode.IDebug;
import leetcode.helper.H;

public class Solution implements IDebug {
	public int maxDistance(int[] nums1, int[] nums2) {
		int len1 = nums1.length;
		int len2 = nums2.length;
		int p1 = 0, p2 = 0;
		int ans = 0;// 最小值不是min啊
		while (p1 < len1 && p2 < len2) {
			int num1 = nums1[p1];
			int num2 = nums2[p2];
			while (p2 < len2) {
				num2 = nums2[p2];
				if (num2 >= num1) {
					p2++;
				} else {
					break;
				}
			}
			ans = Math.max(ans, p2 - p1 - 1);
			p1++;
		}
		return ans;
	}

	@Override
	public void debug4() {
		H.compare(1, this.maxDistance(H.str2array3("[2,2,2]"), H.str2array3("[10,10,1]")));
		H.compare(2, this.maxDistance(H.str2array3("[55,30,5,4,2]"), H.str2array3("[100,20,10,10,5]")));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();
	}
}
